#include <bits/stdc++.h>
#define int long long
using namespace std;

template<typename T>
T read(T x)
{
    T opt = 1, sum = 0;
    char ch = getchar();
    while(!isdigit(ch)) opt = (ch == '-') ? -1 : 1, ch = getchar();
    while( isdigit(ch)) sum = (sum << 1) + (sum << 3) + (ch ^ 48), ch = getchar();
    return opt * sum;
}
#define read read(0ll)
inline void put(int x)
{
    if(x > 9) put(x / 10);
    putchar(x % 10 + 48);
}
const int N = 1e5 + 5;
int ans[N], cnt;
double d[N], v[N], a[N];
int p[N]; map<int, int> mp;
void work()
{
    int n = read, m = read, ll = read;
    double V; cin >> V;
    cnt = 0;
    for(int i = 1;i <= n;i ++ ){
        cin >> d[i] >> v[i] >> a[i];
    }
    for(int i = 1;i <= m;i ++ ) p[i] = read, mp[p[i]] = i;
    sort(p + 1, p + 1 + m);
    int ts = 0, ts1 = 0;
    for(int i = 1;i <= n;i ++ ){
        if(a[i] == 0){
                ts1 = 1;
            if(v[i] > V && d[i] <= p[m]){
                //int k = upper_bound(p + 1, p + 1 + m, d[i]) - p;
                //int res = m - mp[k] + 1;
                ans[++cnt] = i;
            }
        }
        else if(a[i] > 0){
			if(v[i] > V && d[i] <= p[m]) {
				ans[++cnt] = i; continue;}
            ts = 1;
            double k = (V * V - (v[i]) * (v[i])) / (double(2) * (a[i])) + d[i];
            //printf("%.2lf\n", k);
            if((double)k < (double)p[m]){
                ans[++cnt] = i;
            }
        }
    }
    cout << cnt << ' ';
    if(ts == 0 || ts1 == 0) {
        cout << m - (cnt != 0) << endl;
    }
    else {
		cout << m / 2 << endl;
	}
}
signed main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T = read;
    while(T -- ) work();
    return 0;
}
/*
 1
 1 5 15 3
 1 1 4
 2 5 8 9 15
 * */
